package jbit.action;

import jbit.entity.ClaimVoucher;
import jbit.entity.Employee;
import jbit.service.ClaimVoucherService;
import jbit.service.EmployeeService;
import jbit.constants.*;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;


public class EmployeeAction extends ActionSupport{
	private static final long setialVersionUID=-4565898601842133546L;
	private EmployeeService employeeService=null;
	private Employee currentUser=null;
	private ClaimVoucher claimV;

	
	public String login() throws Exception{
		
		ActionContext ac = ActionContext.getContext();
		Employee loginUser=employeeService.login(currentUser);
		String ret=INPUT;
		if(loginUser==null){
			ret=INPUT;
		}else{
			ac.getSession().put("employee",loginUser);
			String nameCn=loginUser.getSysPosition().getNameCn();
			
			if(Constants.POSITION_STAFF.equals(nameCn)){//员工
				ret="staff";
			}else if(Constants.POSITION_FM.equals(nameCn)){//部门经理
				ret = "deptManager";
			}else if(Constants.POSITION_GM.equals(nameCn)){//总经理
				ret = "manager";
			}else if(Constants.POSITION_CASHIER.equals(nameCn)){//财务
				ret = "cashier";
			}
		}
		return ret;
	}

	public EmployeeService getEmployeeService() {
		return employeeService;
	}

	public void setEmployeeService(EmployeeService employeeService) {
		this.employeeService = employeeService;
	}

	public Employee getCurrentUser() {
		return currentUser;
	}

	public void setCurrentUser(Employee currentUser) {
		this.currentUser = currentUser;
	}
}
